import { ElMessageBox } from "element-plus";
import { getStoreOrderDetail } from "@/api/order/store";

// 检查状态是否有改变 有则提示进行更新页面
export const checkOrderStatus = orderData => {
  return new Promise(async resolve => {
    let parasm = {
      bizType: 2,
      id: orderData.id
    };
    let { data } = await getStoreOrderDetail(parasm);
    let newOrderStatus = data.status;
    let nowOrderStatus = orderData.status;
    if (newOrderStatus === nowOrderStatus) {
      resolve(true);
      return;
    }

    ElMessageBox.alert(
      "当前数据订单状态已发生变更，请点击确认进行刷新！",
      "温馨提示",
      {
        showClose: true,
        confirmButtonText: "确认",
        callback: action => {
          if (action == "confirm") {
            resolve(false);
          }
        }
      }
    );
  });
};
